<!DOCTYPE html>
<html>
<head>
    <title>定时任务管理</title>
    <#include "/include/base/header.ftl">
</head>
<body>
<div class="wrapper">
    <div class="main-content">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title"><i class="fa fa-gg"></i>配置管理</div>
                <div class="box-tools pull-right">
                    <@shiro.hasPermission name="mall:sys:task:form">
                        <a href="javascript:void(0);" onclick="tableDialog(this)" class="btn btn-default" data-height="500" data-type="form" data-title="新增任务" data-href="${ctx}/mall/sys/task/form"><i class="fa fa-plus"></i> 新增</a>
                    </@shiro.hasPermission>
                </div>
            </div>
            <div class="box-body">
                <form id="searchForm" action="${ctx}/mall/sys/task/dataList" class="form-inline" onsubmit="return search();">
                    <div class="form-group">
                        <label class="control-label">会员名称：</label>
                        <div class="control-inline">
                            <input type="text" name="memberName" value="" maxlength="100" class="form-control width-120" autocomplete="off" />
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-sm">查询</button>
                        <button type="reset" class="btn btn-default btn-sm">重置</button>
                    </div>
                </form>
                <table id="datatable" class="table table-hover table-striped table-bordered"></table>
            </div>
        </div>
    </div>
</div>
</body>
<#include "/include/base/footer.ftl">
<#include "/include/pagelist.ftl">
<script>
    $(function () {
        $("#datatable").datatable([
            { field: "taskName", title: "任务名称", align: "left", width: "300" },
            { field: "taskClass", title: "执行类", align: "left", width: "300" },
            { field: "taskMethod", title: "执行方法", align: "left", width: "200" },
            { field: "taskCron", title: "cron表达式", align: "center" },
            { field: "showStatus", title: "启用状态", align: "center", width: "200" },
            {
                title: "操作",align: 'center', sortable: false,
                formatter: function(value, row, index){
                    var str = "";
                    <@shiro.hasPermission name="mall:sys:task:ctrl">
                    if(row.status == "1"){
                        str += '<a class="list-btn" href="javascript:void(0);" onclick="tableDialog(this)" data-type="confirm" data-title="确定停止任务?" data-href="${ctx}/mall/sys/task/ctrl?id='+row.id+'&status=0"><span>停止</span></a>';
                    }else{
                        str += '<a class="list-btn" href="javascript:void(0);" onclick="tableDialog(this)" data-type="confirm" data-title="确定启用任务?" data-href="${ctx}/mall/sys/task/ctrl?id='+row.id+'&status=1"><span>启用</span></a>';
                    }
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="mall:sys:task:form">
                        str += '<a class="list-btn" href="javascript:void(0);" onclick="tableDialog(this)" data-type="form" data-title="编辑任务" data-href="${ctx}/mall/sys/task/form?id='+row.id+'"><i class="fa fa-pencil"></i></a>';
                    </@shiro.hasPermission>
                    if(str == ""){ str = "-"; }
                    return str;
                }
            }
        ])
    })
</script>
</html>